package com.liu.controller;

import com.fasterxml.jackson.core.type.TypeReference;
import com.liu.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName TestController
 * @Author liuxin
 * @Date Created in 2023-01-11 11:58
 * @Version 1.0
 */

@RestController
//@CrossOrigin

public class TestController {

//    @CrossOrigin

    @Resource
    private RedisTemplate redisTemplate;

    @GetMapping("test")
    public String test(){
        List<String> list = new ArrayList<>();
        list.add("liuxin");
        list.add("liuyutao");
        list.add("liuxinnixiang");
        String map = redisTemplate.setObject("map", list, -1L);
        List<String> map1 = redisTemplate.getObject("map", new TypeReference<List<String>>() {});
        return map1.toString();
    }
}
